package com.ck.demo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CodeDemo {

    public static void main(String[] args) {

        String codeStr = "【鹰硕】鹰硕验证码: 747931 ，切勿向任何人泄33277露此验证码";
        //使用正则表达式获取codeStr中连续的数字
        String regex = "\\d+";
        Matcher matcher = Pattern.compile(regex).matcher(codeStr);
        StringBuffer sb = new StringBuffer();
        String code = "";
        while (matcher.find()) {
            String group = matcher.group();
            System.out.println(group);
            sb.append(group);
            if(group.length() >= 4 && group.length() <= 6){
                code = group;
            }
        }
        System.out.println(code);


    }

}
